<?php TPL::output('admin/global/header.tpl.htm'); ?>
<?php TPL::output('admin/global/nav_menu.tpl.htm'); ?>

<div class="aw-content-wrap">
    <div class="mod">
        <div class="mod-head">
            <h3>
                <span class="pull-left"><?php _e('编辑用户资料'); ?></span>
            </h3>
        </div>
        <div class="tab-content mod-content">
            <form action="admin/ajax/remove_user/" method="post" id="remove_user_form">
            <table class="table">
                <tr>
                    <td>
                        <div class="form-group">
                            <span class="col-sm-4 col-xs-3 control-label"><?php _e('删除用户'); ?>:</span>
                            <div class="col-sm-7 col-xs-8">
                                <input type="hidden" name="uid" value="<?php echo $this->user['uid']; ?>" />

                                <label><input name="remove_user" id="remove_user" type="checkbox" value="1" /> <?php _e('确认删除这个用户'); ?></label>

                                <label><input name="remove_user_data" id="remove_user_data" type="checkbox" value="1" /> <?php _e('删除用户发布的内容'); ?></label>

                                <a class="btn btn-danger btn-xs" onclick="if (!document.getElementById('remove_user').checked) { AWS.alert('<?php _e('请先确认删除操作'); ?>'); } else { AWS.ajax_post($('#remove_user_form')); }"><?php _e('删除用户'); ?></a>

                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            </form>
                <form action="admin/ajax/save_user/" id="settings_form" enctype="multipart/form-data" method="post" onsubmit="return false">
                <table class="table table-striped">
                    <input name="uid" type="hidden" value="<?php echo $this->user['uid']; ?>" />
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('用户名'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="user_name" type="text" value="<?php echo $this->user['user_name']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('邮箱'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="email" type="text" value="<?php echo $this->user['email']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('密码'); ?>:</span>
                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="password" type="password" value="" />

                                    <span class="help-block"><?php _e('不更改请留空'); ?></span>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('居住地'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <select name="province" class="select_area form-control"></select>
                                </div>
                                <div class="col-sm-3 col-xs-3">
                                    <select name="city" class="select_area form-control collapse"></select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('职业'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <select name="job_id" class="form-control">
                                        <option value="">--</option>
                                        <?php echo H::display_options($this->job_list, $this->user['job_id']); ?>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('手机号码'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="mobile" type="text" value="<?php echo $this->user['mobile']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label">QQ:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="qq" type="text" value="<?php echo $this->user['qq']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('常用邮箱'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="common_email" type="text" value="<?php echo $this->user['common_email']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('网站'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="homepage" type="text" value="<?php echo $this->user['homepage']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('一句话介绍'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="signature" type="text" value="<?php echo $this->user['signature']; ?>" />
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('积分'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <?php echo $this->user['integral']; ?> &nbsp; <a class="btn btn-xs btn-danger" href="admin/user/integral_log/uid-<?php echo $this->user['uid']; ?>"><?php _e('操作积分'); ?></a>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('邮箱激活状态'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="valid_email" value="1"<?php if ($this->user['valid_email'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="valid_email" value="0"<?php if ($this->user['valid_email'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('认证用户'); ?>:</span>
                                <div class="col-sm-8 col-xs-8">
                                    <label class="checkbox-inline"><input type="radio" name="verified" value=""<?php if ($this->user['verified'] == '') { ?> checked="checked"<?php } ?> /><?php _e('无'); ?></label>
                                    <label class="checkbox-inline"><input type="radio" name="verified" value="personal"<?php if ($this->user['verified'] == 'personal') { ?> checked="checked"<?php } ?> /><?php _e('个人认证'); ?></label>
                                    <label class="checkbox-inline"><input type="radio" name="verified" value="enterprise"<?php if ($this->user['verified'] == 'enterprise') { ?> checked="checked"<?php } ?>/><?php _e('机构认证'); ?></label>
                                    &nbsp; <a href="admin/user/verify_approval_edit/<?php echo $this->user['uid']; ?>" class="btn btn-xs btn-danger"><?php _e('编辑认证审核资料'); ?></a>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('头像'); ?>:</span>
                                <div class="col-sm-2">
                                    <p>
                                        <img src="<?php echo get_avatar_url($this->user['uid'], 'mid'); ?>" alt="" class="img-polaroid" />
                                    </p>
                                    <span class="mod-file">
                                        <input type="button" class="btn btn-primary" value="点击更换头像">
                                        <input type="file" name="user_avatar" exts="png|jpg|bmp|jpeg" class="mod-input-file">
                                    </span><br>
                                    <p class="filetext"></p>
                                    <label><input name="delete_avatar" type="checkbox" value="1" /> <?php _e('删除头像'); ?></label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('会员组'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <?php echo $this->mem_group['group_name']; ?>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('系统组'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <select name="group_id" class="form-control">
                                        <?php foreach ($this->system_group as $skey => $val) { ?>
                                        <?php if ($val['group_id'] == 1 AND !$this->user_info['permission']['is_administortar']) { continue; } ?>
                                        <option value="<?php echo $val['group_id']; ?>"<?php if ($this->user['group_id'] == $val['group_id']) { ?> selected="selected"<?php } ?>><?php echo $val['group_name']; ?></option>
                                        <?php } ?>
                                    </select>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('封禁用户'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="forbidden" value="1"<?php if ($this->user['forbidden'] == 1) { ?> checked="checked"<?php } ?> /> <?php _e('是'); ?>
                                        </label>

                                        <label type="button" class="btn mod-btn-color">
                                            <input type="radio" name="forbidden" value="0"<?php if ($this->user['forbidden'] == 0) { ?> checked="checked"<?php } ?> /> <?php _e('否'); ?>
                                        </label>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('注册时间'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <?php echo date_friendly($this->user['reg_time']); ?>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <?php if ($this->user['reg_ip']) { ?>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('注册 IP'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <?php echo long2ip($this->user['reg_ip']); ?>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>

                    <?php if ($this->user['last_ip']) { ?>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('上次登录 IP'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <?php echo long2ip($this->user['last_ip']); ?>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>

                    <?php if ($this->user['last_login']) { ?>
                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('上次登录时间'); ?>:</span>
                                <div class="col-sm-6 col-xs-8">
                                    <div class="btn-group mod-btn">
                                        <?php echo date_friendly($this->user['last_login']); ?>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                    <?php } ?>

                    <tr>
                        <td>
                            <div class="form-group">
                                <span class="col-sm-4 col-xs-3 control-label"><?php _e('性别'); ?>:</span>
                                <div class="col-sm-8 col-xs-8">
                                    <label class="checkbox-inline"><input type="radio" name="sex" value="1"<?php if ($this->user['sex'] == 1) { ?> checked="checked"<?php } ?> /><?php _e('男'); ?></label>
                                    <label class="checkbox-inline"><input type="radio" name="sex" value="2"<?php if ($this->user['sex'] == 2) { ?> checked="checked"<?php } ?> /><?php _e('女'); ?></label>
                                    <label class="checkbox-inline"><input type="radio" name="sex" value="3"<?php if (!$this->user['sex'] OR $this->user['sex'] == 3) { ?> checked="checked"<?php } ?>/><?php _e('保密'); ?></label>
                                </div>
                            </div>
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <div class="form-group">
                                <label class="col-sm-4 col-xs-3 control-label"><?php _e('可用邀请名额'); ?>:</label>

                                <div class="col-sm-5 col-xs-8">
                                    <input class="form-control" name="invitation_available" type="text" value="<?php echo $this->user['invitation_available']; ?>"/>
                                </div>
                            </div>
                        </td>
                    </tr>

                <tfoot>
                <tr>
                    <td>
                        <input type="button" value="<?php _e('保存设置'); ?>" class="btn btn-primary center-block" onclick="AWS.ajax_post($('#settings_form'));" />
                    </td>
                </tr>
                </tfoot>
            </table>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
$(document).ready(function () {
    $('.select_area').LocationSelect({
        labels: ["<?php _e('请选择省份或直辖市'); ?>", "<?php _e('请选择城市'); ?>"],
        elements: document.getElementsByTagName("select"),
        detector: function () {
            this.select(["<?php echo $this->user['province']; ?>", "<?php echo $this->user['city']; ?>"]);
        },
        dataUrl: G_BASE_URL.replace('/?', '') + '/static/js/areas.js'
    });

    $('.mod-input-file').change(function(){
        $('.filetext').text($('.mod-input-file').val());
    });
});
</script>

<?php TPL::output('admin/global/footer.tpl.htm'); ?>